import * as type from './type'
import http from 'Utils/http'

const actions = {
    // 请求一级分类列表数据
    async getCFList({ commit }, value) {
        const result = await http('https://wcgi.jianke.com/category/api/fullCategories', {
            platform: value.platform
        })

        let action = {
            type: type['CFLIST'],
            payload: result
        }

        commit(action)
    },
    // 请求二级分类列表数据
    async getCSList({ commit }, value) {
        const result = await http('https://wcgi.jianke.com/category/api/fullCategories', {
            pid: value.pid,
            platform: value.platform
        })

        let action = {
            type: type['CSLIST'],
            payload: result
        }

        commit(action)
    },
    // 请求搜索热词列表数据
    async getWordsList({ commit }, value) {
        const result = await http('https://mbp.jianke.com/mbm/mall/api/searchword/getWords')

        let action = {
            type: type['WORDSLIST'],
            payload: result
        }

        commit(action)
    }
}

export default actions